package it.tcon.xbeedriver;

import com.rapplogic.xbee.api.XBee;
import com.rapplogic.xbee.api.XBeeException;
import com.rapplogic.xbee.api.XBeeResponse;


public class XBeeReceiver implements Runnable {

	private XBee xbee;
	private XBeeResponse response;
	private Thread rcThread;
	private XBeeReceiveController receiveController;
	private XBeeNodeList list;
	
	public XBeeReceiver(XBee xbee,XBeeNodeList list){
		this.xbee = xbee;
		this.list = list;
	}
	
	public void run() {
		
		
		try {
			while(true){
				
				response = xbee.getResponse();
				
				receiveController = new XBeeReceiveController(this.response,this.list);
				
				rcThread = new Thread(receiveController);
				rcThread.start();
			}
			
		} catch (XBeeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
